<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 200px;
            height: 200px;
            background: yellow;
        }
    </style>
</head>
<body>
    <button>添加</button>
    <button>移除</button>
    <div class="box"></div>
    <script>
        oBtns=document.querySelectorAll("button");
        oBox=document.querySelector(".box");
        var fn=function(){
            console.log("我这个是动态添加的的");
        }

        oBtns[0].onclick=function(){
            oBox.addEventListener("click",fn)
        }
        oBtns[1].onclick=function(){
            oBox.removeEventListener("click",fn)
        }
    </script>
</body>
</html>